<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Page extends MY_Controller {
    
	public function __construct(){
		parent::__construct();
	}
	
	function about_us(){
	    $this->_data['sm_about'] = 'csm';
		$this->load->view('page/about_us',$this->_data);
	}
	
	function help_center(){
	    $this->_data['sm_help'] = 'csm';
	    $this->load->view('page/help_center',$this->_data);
	}
	
	function policy(){
   	    $this->_data['sm_about'] = 'csm';
		$this->load->view('page/policy',$this->_data);
	}
	
	function contact_us(){
   	    $this->_data['sm_contact'] = 'csm';
		$this->load->view('page/contact_us',$this->_data);
	}
	
	function board(){
	    
	    $this->load->library('pagination');
	    $limit_num = !empty($_GET['per_page']) ? intval($_GET['per_page']) : 0;
	    
	    $this->load->model('board_model','board');
	    $list = $this->board->get_by_page($limit_num);
	    $this->_data['list_board'] = $list;
	    
	    //分页导航
	    $this->pagination->initialize(config_item('pagefollow')); 
    	$this->pagination->base_url = $this->page_url();;
	    $this->pagination->total_rows = $this->board->count;
	    $this->_data['pagenav'] = $this->pagination->create_links();
	    
	    $this->_data['sm_board'] = 'csm';
		$this->load->view('page/board',$this->_data);
		
	}
	
	function board_do(){
	    
		$this->check_ajax_login();

		//数据检测
		if(empty($this->p['cont'])) die;
		$this->p['poster_id'] = $this->loginer->id;

		$this->cm->save($this->tbl->board,$this->p);

		ejd('','','reload');
	}
	
	function board_del(){
	    
		$this->check_ajax_login();

		//数据检测
		if(empty($this->p['id'])) die;

		$this->cm->delete($this->tbl->board,array('id'=>$this->p['id']));

		ejd('','','reload');
	}
	
	
	
}
